package com.dingwei.superiordiary.adapter.adapter;

import android.content.Context;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bobomee.android.mentions.text.MentionTextView;
import com.dingwei.superiordiary.R;
import com.dingwei.superiordiary.bean.MyLikesBean;
import com.dingwei.superiordiary.parser.Parser;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;
import com.jude.easyrecyclerview.adapter.RecyclerArrayAdapter;
import com.lihao.baselibrary.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by lihao on 2018/1/11.
 */

public class MyLikesAdapter extends RecyclerArrayAdapter<MyLikesBean.DataBean.ListBean> {
    public MyLikesAdapter(Context context) {
        super(context);
    }

    private Parser mTagParser = new Parser();

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyCollectHolder(parent);
    }


    class MyCollectHolder extends BaseViewHolder<MyLikesBean.DataBean.ListBean> {


        @Bind(R.id.tv_nick_name)
        TextView tvNickName;
        @Bind(R.id.tv_activity_time)
        TextView tvActivityTime;
        @Bind(R.id.tv_content)
        MentionTextView tvContent;
        @Bind(R.id.img_size)
        TextView imgSize;
        @Bind(R.id.img_layout)
        LinearLayout imgLayout;
        @Bind(R.id.img_video)
        ImageView imgVideo;
        @Bind(R.id.tv_like_time)
        TextView tvLikeTime;

        public MyCollectHolder(ViewGroup parent) {
            super(parent, R.layout.item_my_likes);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(MyLikesBean.DataBean.ListBean data) {
            super.setData(data);

            tvContent.setMovementMethod(new LinkMovementMethod());
            tvContent.setParserConverter(mTagParser);
            tvContent.setHighlightColor(BaseActivity.context.getResources().getColor(android.R.color.transparent));

            tvNickName.setText(data.nickname);
            tvActivityTime.setText(data.activity_addtime);
            tvContent.setText(data.content);

            switch (data.data_type) {
                case 1:
                    imgLayout.setVisibility(View.VISIBLE);
                    imgSize.setText(data.image_num + "");
                    imgVideo.setVisibility(View.GONE);
                    break;
                case 2:
                    imgLayout.setVisibility(View.GONE);
                    imgVideo.setVisibility(View.VISIBLE);
                    break;
                case 3:
                    imgLayout.setVisibility(View.GONE);
                    imgVideo.setVisibility(View.GONE);
                    break;
            }
            tvLikeTime.setText("点赞日期" + data.addtime);

        }
    }
}
